using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Omniture.API.Generators.Objects;
using Omniture.API.Generators.Properties;

namespace Omniture.API.Generators
{
	public static class GenerationHelper
	{
		#region Methods

		public static void Generate(OmnitureProject project, bool deleteSource, out string tempFolder)
		{
			tempFolder = "";

			//Add Generators
			Omniture.API.Generators.Generator generator = new Omniture.API.Generators.Generator(project, project.LibraryFilePath, "");
			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.PluginTemplate(project));
			//generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EvarRuntimeItemCollectionTemplate(project));
			//generator.GeneratorList.Add(new Omniture.API.Generators.Objects.PropRuntimeItemCollectionTemplate(project));
			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EventRuntimeItemCollectionTemplate(project));

			//Add strong types
			foreach (ITrackItem item in project.EventList)
			{
				generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EventRuntimeItemStrongTypeTemplate(project, item));
			}
			foreach (ITrackItem item in project.PropList)
			{
				generator.GeneratorList.Add(new Omniture.API.Generators.Objects.PropRuntimeItemStrongTypeTemplate(project, item));
			}
			foreach (ITrackItem item in project.EVarList)
			{
				generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EvarRuntimeItemStrongTypeTemplate(project, item));
			}			

			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EvarRuntimeItemTemplate(project));
			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.PropRuntimeItemTemplate(project));
			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.EventRuntimeItemTemplate(project));
			generator.GeneratorList.Add(new Omniture.API.Generators.Objects.PageCacheItemTemplate(project));
			generator.GeneratorList.Add(new Omniture.API.Generators.Properties.AssemblyInfoTemplate(project));

			//Add References			
			generator.IncludeFileList.Add(System.Reflection.Assembly.GetExecutingAssembly().Location);

			//Perform actual generation
			generator.Generate(deleteSource, out tempFolder);

		}

		#endregion

	}
}
